﻿using System;
using System.Collections.Generic;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace mozhi.smarterp.BasicData
{
    public class AggregateRootBase : AuditedAggregateRoot<Guid>, IMultiTenant
    {
        public virtual bool Activated { protected set; get; }

        public virtual Guid? TenantId { get; protected set; }

        public virtual string Code { protected set; get; }

        public virtual string Name { protected set; get; }

        protected AggregateRootBase()
        {

        }

        public AggregateRootBase(Guid id, string code, string name, bool activate = true)
        {
            Id = id;
            Code = code;
            Name = name;
            Activated = activate;
            
        }

        public void Change(string code, string name, bool activated)
        {
            Code = code;
            Name = name;
            Activated = activated;

            
        }

        protected virtual void Validate()
        {
            if (Code.IsNullOrEmpty())
                throw new UserFriendlyException("编码不能为空");

            if (Name.IsNullOrEmpty())
                throw new UserFriendlyException("名称不能为空");
        }
    }
}
